//
//  Release_JobInfo.m
//  HappyStore
//
//  Created by 点点充 on 16/1/23.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "Release_JobInfo.h"

@interface Release_JobInfo ()<UICollectionViewDataSource,UICollectionViewDelegate,UITextFieldDelegate>
{
    UICollectionView *mainCollection;
    
    UITextField *tfTitle;
    UITextField *tfZhiWei;
    UITextField *tfPrice;
    
    //行业
    UILabel *labHangYe;
    UILabel *labXueli;
    UILabel *labGZExprce;//工作经验
    
    
    //地区
    UILabel *labAddress;
    NSString *provinceStr;
    NSString *cityStr;
    NSString *districtStr;
    
    
    //标签
    UIButton *btnTagert1;
    UIButton *btnTagert2;
    UIButton *btnTagert3;
    
    UITextView *tvDetail;
    
    
    //发布按钮
    UIButton *btnRelease;
    
    NSMutableArray *muArySaveImg;//保存5张图片
    
    
    BOOL isSelectedHeader;
    
    NSArray *aryIndustry;//行业数据
    NSArray *aryXueLi;//学历
    NSArray *aryExprce;//经验
    
    NSInteger selecType;
    
    
    SingleSelectedDialog *tableViewIndustry;
    
    SelectedAddress *selectAddress;//选择地区
    
    NSString *strID;
    
}
@end

@implementation Release_JobInfo

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBarHidden = NO;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    if ([_strTypee isEqualToString:@"1"]) {
        self.navigationItem.title = @"发布招聘";
    }else {
        self.navigationItem.title = @"发布求职";
    }
    
    
    muArySaveImg = [NSMutableArray arrayWithObject:[UIImage imageNamed:@"re_project_add2"]];
    
    isSelectedHeader = YES;
    
    
    aryIndustry = @[@"互联网",@"金融",@"建筑地产",
                   @"能源矿业",@"交通运输",@"物流",
                   @"商务服务",@"教育培训",@"医疗卫生",
                   @"酒店餐饮",@"旅游度假",@"文化传媒",
                   @"休闲娱乐",@"商贸流通",@"农林牧渔",
                   @"生产制造",@"其他行业"];
    
    aryXueLi = @[@"初中",@"高中",@"大学",@"硕士",@"博士"];
    aryExprce = @[@"不限",@"一年以内",@"1-3年",
                  @"3-5年",@"5-10年",@"10年以上"];
    
    //开启侧滑
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
    
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
            return 370;
            break;
        case 1:
            return 380;
            break;
        default:
            return 80;
            break;
    }
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cell1 = @"cell1";
    static NSString *cell2 = @"cell2";
    
    UITableViewCell *cell;
    
    switch (indexPath.row) {
        case 0://头像＋2行
        {
            cell = [tableView dequeueReusableCellWithIdentifier:cell1 forIndexPath:indexPath];
            
            tfTitle = [cell viewWithTag:10];
            tfZhiWei = [cell viewWithTag:11];
            tfPrice = [cell viewWithTag:12];
            tfPrice.delegate = self;
            if ([_strTypee isEqualToString:@"1"]) {
                tfZhiWei.placeholder = @"请输入您要招聘的职位";
                tfPrice.placeholder = @"请输入薪资";
            }else {
                tfZhiWei.placeholder = @"请输入您要应聘的职位";
                tfPrice.placeholder = @"请输入薪资要求";
            }
            
            
            
            
            if (labHangYe == nil) {
                for (int i = 0; i<4; i++) {
                    switch (i) {
                        case 0://行业
                        {
                            labHangYe = [[UILabel alloc] initWithFrame:(CGRect){25,170+50*i,280,30}];
                            labHangYe.text = @"请选择行业";
                            labHangYe.font = [UIFont systemFontOfSize:12.5f];
                            labHangYe.textColor = [UIColor colorWithWhite:0.75 alpha:1.f];
                            
                            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                            [btn setImage:[UIImage imageNamed:@"re_project_right"] forState:UIControlStateNormal];
                            btn.frame = (CGRect){20,170+50*i,280,30};
                            btn.layer.borderColor = [UIColor colorWithRed:201/255.0f green:202/255.0f blue:202/255.0f alpha:1.0f].CGColor;
                            btn.layer.borderWidth = 0.5f;
                            btn.layer.masksToBounds = YES;
                            btn.layer.cornerRadius = 5.0f;
                            
                            btn.imageEdgeInsets = UIEdgeInsetsMake(0, 280-40+1.5, 0, 0);
                            [btn addTarget:self action:@selector(btnClickHangYe:) forControlEvents:UIControlEventTouchUpInside];
                            
                            [cell addSubview:labHangYe];
                            [cell addSubview:btn];
                        }
                            break;
                        case 1://学历要求
                        {
                            labXueli = [[UILabel alloc] initWithFrame:(CGRect){25,170+50*i,280,30}];
                            labXueli.text = @"请选择学历要求";
                            labXueli.font = [UIFont systemFontOfSize:12.5f];
                            labXueli.textColor = [UIColor colorWithWhite:0.75 alpha:1.f];
                            
                            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                            [btn setImage:[UIImage imageNamed:@"re_project_right"] forState:UIControlStateNormal];
                            btn.frame = (CGRect){20,170+50*i,280,30};
                            btn.layer.borderColor = [UIColor colorWithRed:201/255.0f green:202/255.0f blue:202/255.0f alpha:1.0f].CGColor;
                            btn.layer.borderWidth = 0.5f;
                            btn.layer.masksToBounds = YES;
                            btn.layer.cornerRadius = 5.0f;
                            
                            btn.imageEdgeInsets = UIEdgeInsetsMake(0, 280-40+1.5, 0, 0);
                            [btn addTarget:self action:@selector(btnClickXueLi:) forControlEvents:UIControlEventTouchUpInside];
                            
                            [cell addSubview:labXueli];
                            [cell addSubview:btn];
                        }
                            break;
                        case 2://工作经验
                        {
                            labGZExprce = [[UILabel alloc] initWithFrame:(CGRect){25,170+50*i,280,30}];
                            labGZExprce.text = @"请选择工作经验";
                            labGZExprce.font = [UIFont systemFontOfSize:12.5f];
                            labGZExprce.textColor = [UIColor colorWithWhite:0.75 alpha:1.f];
                            
                            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                            [btn setImage:[UIImage imageNamed:@"re_project_right"] forState:UIControlStateNormal];
                            btn.frame = (CGRect){20,170+50*i,280,30};
                            btn.layer.borderColor = [UIColor colorWithRed:201/255.0f green:202/255.0f blue:202/255.0f alpha:1.0f].CGColor;
                            btn.layer.borderWidth = 0.5f;
                            btn.layer.masksToBounds = YES;
                            btn.layer.cornerRadius = 5.0f;
                            
                            btn.imageEdgeInsets = UIEdgeInsetsMake(0, 280-40+1.5, 0, 0);
                            [btn addTarget:self action:@selector(btnClickGongZuoExprce:) forControlEvents:UIControlEventTouchUpInside];
                            
                            [cell addSubview:labGZExprce];
                            [cell addSubview:btn];
                        }
                            break;
                        case 3://地区
                        {
                            labAddress = [[UILabel alloc] initWithFrame:(CGRect){25,170+50*i,280,30}];
                            labAddress.font = [UIFont systemFontOfSize:12.5f];
                            labAddress.textColor = [UIColor colorWithWhite:0.75 alpha:1.f];
                            labAddress.text = @"请选择地区";
                            
                            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                            [btn setImage:[UIImage imageNamed:@"re_project_right"] forState:UIControlStateNormal];
                            btn.frame = (CGRect){20,170+50*i,280,30};
                            btn.layer.borderColor = [UIColor colorWithRed:201/255.0f green:202/255.0f blue:202/255.0f alpha:1.0f].CGColor;
                            btn.layer.borderWidth = 0.5f;
                            btn.layer.masksToBounds = YES;
                            btn.layer.cornerRadius = 5.0f;
                            
                            btn.imageEdgeInsets = UIEdgeInsetsMake(0, 280-40+1.5, 0, 0);
                            [btn addTarget:self action:@selector(btnClickAddress) forControlEvents:UIControlEventTouchUpInside];
                            
                            [cell addSubview:labAddress];
                            [cell addSubview:btn];
                        }
                            break;
                    }
                    
                }
            }
            
        }
            break;
        case 1://标签＋文本输入框+发布
        {
            cell = [tableView dequeueReusableCellWithIdentifier:cell2 forIndexPath:indexPath];
            
            tvDetail = [cell viewWithTag:10];
            tvDetail.layer.masksToBounds = YES;
            tvDetail.layer.cornerRadius = 5.f;
            tvDetail.delegate = self;
            tvDetail.layer.borderColor = [UIColor colorWithRed:201/255.0f green:202/255.0f blue:202/255.0f alpha:1.0f].CGColor;
            tvDetail.layer.borderWidth = 0.5f;
            tvDetail.font = [UIFont systemFontOfSize:12.5f];
            tvDetail.textColor = [UIColor colorWithWhite:0.75 alpha:1.f];
            if (tvDetail.text.length == 0) {
                tvDetail.text = @"请对你发布的内容进行一个详细的描述";
            }
            
            mainCollection = [cell viewWithTag:11];
            mainCollection.delegate = self;
            mainCollection.dataSource = self;
            
            btnTagert1 = [cell viewWithTag:12];
            btnTagert2 = [cell viewWithTag:13];
            btnTagert3 = [cell viewWithTag:14];
            [btnTagert1 addTarget:self action:@selector(btnClickTagert:) forControlEvents:UIControlEventTouchUpInside];
            [btnTagert2 addTarget:self action:@selector(btnClickTagert:) forControlEvents:UIControlEventTouchUpInside];
            [btnTagert3 addTarget:self action:@selector(btnClickTagert:) forControlEvents:UIControlEventTouchUpInside];
            
            btnTagert1.layer.masksToBounds = YES;
            btnTagert1.layer.cornerRadius = 5.f;
            btnTagert2.layer.masksToBounds = YES;
            btnTagert2.layer.cornerRadius = 5.f;
            btnTagert3.layer.masksToBounds = YES;
            btnTagert3.layer.cornerRadius = 5.f;
            
            
            btnRelease = [cell viewWithTag:15];
            btnRelease.layer.masksToBounds = YES;
            btnRelease.layer.cornerRadius= 5.f;
            [btnRelease addTarget:self action:@selector(btnClickRelease) forControlEvents:UIControlEventTouchUpInside];
            
            
        }
            break;
    }
    
    
    
    return cell;
    
}

#pragma mark - 选择头像
- (void)btnClickAddHeader
{
    isSelectedHeader = YES;
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"照片选择"
                                                             delegate:self
                                                    cancelButtonTitle:@"取消"
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:@"相机",@"相册", nil];
    actionSheet.tag = 333;
    [actionSheet showInView:self.view];
}


#pragma mark - 选择行业
- (void)btnClickHangYe:(UIButton *)sender
{
    selecType = 1;
    tableViewIndustry = [SingleSelectedDialog sharedSelectedAddress];
    tableViewIndustry.delegatee = self;
    [tableViewIndustry btnClickAddressWithData:aryIndustry];
}

- (void)seceltedRow:(NSInteger)rrow
{
    switch (selecType) {
        case 1://行业
        {
            labHangYe.text = aryIndustry[rrow];
            labHangYe.textColor = [UIColor colorWithRed:137/255.0f green:137/255.0f blue:137/255.0f alpha:1.0f];
        }
            break;
        case 2://学历
        {
            labXueli.text = aryXueLi[rrow];
            labXueli.textColor = [UIColor colorWithRed:137/255.0f green:137/255.0f blue:137/255.0f alpha:1.0f];
        }
            break;
        case 3://工作经验
        {
            labGZExprce.text = aryExprce[rrow];
            labGZExprce.textColor = [UIColor colorWithRed:137/255.0f green:137/255.0f blue:137/255.0f alpha:1.0f];
        }
            break;
    }
    
    
}


#pragma mark - 选择学历
- (void)btnClickXueLi:(UIButton *)sender
{
    selecType = 2;
    tableViewIndustry = [SingleSelectedDialog sharedSelectedAddress];
    tableViewIndustry.delegatee = self;
    [tableViewIndustry btnClickAddressWithData:aryXueLi];
}

#pragma mark - 选择工作经验
- (void)btnClickGongZuoExprce:(UIButton *)sender
{
    selecType = 3;
    tableViewIndustry = [SingleSelectedDialog sharedSelectedAddress];
    tableViewIndustry.delegatee = self;
    [tableViewIndustry btnClickAddressWithData:aryExprce];
}


#pragma mark - 选择地区
- (void)btnClickAddress
{
    selectAddress = [SelectedAddress sharedSelectedAddress];
    selectAddress.delegatee = self;
    [selectAddress btnClickAddress];
}

- (void)seceltedRowSshowMsg:(NSString *)showMsg andProvince:(NSString *)strProvince andCity:(NSString *)strCity andDistrict:(NSString *)strDistrict
{
    labAddress.text = showMsg;
    labAddress.textColor = [UIColor colorWithRed:137/255.0f green:137/255.0f blue:137/255.0f alpha:1.0f];
    provinceStr = strProvince;
    cityStr = strCity;
    districtStr = strDistrict;
}



#pragma mark - 选择标签
- (void)btnClickTagert:(UIButton *)sender
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"添加标签" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    UITextField *nameField = [alert textFieldAtIndex:0];
    nameField.placeholder = @"最多输入4个字";
    
    [alert showAlertWithCompletionHandler:^(NSInteger buttonIndex) {
        if(buttonIndex == 1){
            UITextField *tf=[alert textFieldAtIndex:0];
            if (tf.text.length > 0 && tf.text.length < 5) {
                [sender setTitle:tf.text forState:UIControlStateNormal];
                [sender setImage:nil forState:UIControlStateNormal];
                sender.backgroundColor = [UIColor colorWithRed:32/255.f green:165/255.f blue:240/255.f alpha:1.f];
            }else {

                [self showSingleIconBubble:@"最多输入4个字"];

            }
        }
    }];
    
}





#pragma mark- UICollectionViewDelegate
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
//个数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return muArySaveImg.count;
    
}
//行内容
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    static NSString *cell1 = @"cell1";
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cell1 forIndexPath:indexPath];
    
    //    NSLog(@"子视图:%@",cell.subviews);
    
    UIButton *btnImage = [cell viewWithTag:10];
    btnImage.layer.masksToBounds = YES;
    btnImage.layer.cornerRadius = 5.f;
    [btnImage setImage:muArySaveImg[indexPath.row] forState:UIControlStateNormal];
    [btnImage addTarget:self action:@selector(btnClickAddImage:) forControlEvents:UIControlEventTouchUpInside];
    btnImage.hidden = NO;
    btnImage.userInteractionEnabled = YES;
    
    UIButton *btnDelete = [cell viewWithTag:11];
    btnDelete.hidden = NO;
    [btnDelete addTarget:self action:@selector(btnClickDeleteImage:) forControlEvents:UIControlEventTouchUpInside];
    
    //    NSLog(@"子视图:%@",btnDelete.superview);
    
    if (muArySaveImg.count == 1 || indexPath.row == muArySaveImg.count-1) {
        btnDelete.hidden = YES;
    }else {
        btnImage.userInteractionEnabled = NO;
    }
    
    if (muArySaveImg.count == 6 && indexPath.row == muArySaveImg.count -1) {
        btnImage.hidden = YES;
        btnDelete.hidden = YES;
    }
    
    
    
    return cell;
}

#pragma mark - 添加5张图片
- (void)btnClickAddImage:(UIButton *)sender
{
    isSelectedHeader = NO;
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"照片选择"
                                                             delegate:self
                                                    cancelButtonTitle:@"取消"
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:@"相机",@"相册", nil];
    actionSheet.tag = 333;
    [actionSheet showInView:self.view];
}

#pragma mark - 选择照片
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    switch (actionSheet.tag) {
        case 222:
        {
            
        }
            break;
        case 333:
        {
            //先设定sourceType为相机，然后判断相机是否可用（ipod）没相机，不可用将sourceType设定为相片库
            UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];
            pickerImage.delegate = self;
            pickerImage.allowsEditing = YES;//设置可编辑
            switch (buttonIndex) {
                case 0:
                {
                    //NSLog(@"相机");
                    pickerImage.sourceType = UIImagePickerControllerSourceTypeCamera;
                    [self presentViewController:pickerImage animated:YES completion:nil];//进入照相界面
                }
                    break;
                case 1:
                {
                    //NSLog(@"相册");
                    pickerImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //图片库
                    [self presentViewController:pickerImage animated:YES completion:nil];//进入照相界面
                }
                    break;
                case 2:
                {
                    //NSLog(@"取消");
                }
                    break;
            }
        }
            break;
    }
    
}

//点击相册中的图片 货照相机照完后点击use  后触发的方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [picker dismissViewControllerAnimated:YES completion:^{}];
    
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
    
    if (isSelectedHeader) {//选择的头像
        //        fullPathHeader = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:strName];
//        [btnAddHeader setImage:image forState:UIControlStateNormal];
//        btnDeleHeader.hidden = NO;
    }else {
        //5张详情 图片
        [muArySaveImg insertObject:image atIndex:0];
        if (muArySaveImg.count == 2) {
            [muArySaveImg replaceObjectAtIndex:1 withObject:[UIImage imageNamed:@"re_project_add3"]];
        }
        
        if (muArySaveImg.count == 4) {
            [_mainTableView reloadData];
        }
        
        [mainCollection reloadData];
    }
    
}

//点击cancel 调用的方法
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [picker dismissViewControllerAnimated:YES completion:^{}];
}

#pragma mark - 保存图片至沙盒
- (void) saveImage:(UIImage *)currentImage withName:(NSString *)imageName
{
    NSData *imageData = UIImageJPEGRepresentation(currentImage, 0.1);
    // 获取沙盒目录
    NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
    // 将图片写入文件
    [imageData writeToFile:fullPath atomically:NO];
}

#pragma mark - 删除5张图片
- (void)btnClickDeleteImage:(UIButton *)sender
{
    UIView *viewContent = sender.superview;
    
    NSIndexPath *indexPath = [mainCollection indexPathForCell:(UICollectionViewCell *)viewContent.superview];
    //NSLog(@"--------%ld",indexPath.row);
    [muArySaveImg removeObjectAtIndex:indexPath.row];
    
    [mainCollection reloadData];
    
    if (muArySaveImg.count == 3) {
        [_mainTableView reloadData];
    }
}


#pragma mark 照片的时间名称
- (NSString*)dateString
{
    NSMutableString*string=[[NSMutableString alloc] init];
    NSDate*dayDate=[NSDate date];
    NSDateFormatter*dayFormatter=[[NSDateFormatter alloc] init];
    [dayFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *dateStrings= [dayFormatter stringFromDate:dayDate];
    NSArray*dayArray=[dateStrings componentsSeparatedByString:@"-"];
    for (int i=0; i<[dayArray count]; i++) {
        [string appendFormat:@"%@",[dayArray objectAtIndex:i]];
    }
    NSDate*timeDate=[NSDate date];
    NSDateFormatter*timeFormatter=[[NSDateFormatter alloc] init];
    [timeFormatter setDateFormat:@"HH:mm:ss:SSS"];
    NSString *timeString= [timeFormatter stringFromDate:timeDate];
    NSArray*timeArray=[timeString componentsSeparatedByString:@":"];
    for (int i=0; i<[timeArray count]; i++) {
        [string appendFormat:@"%@",[timeArray objectAtIndex:i]];
    }
    return string;
    
}


- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
    if ([textView.text isEqualToString:@"请对你发布的内容进行一个详细的描述"]) {
        textView.text = @"";
        textView.textColor = [UIColor colorWithRed:137/255.0f green:137/255.0f blue:137/255.0f alpha:1.0f];
    }
    
    return YES;
}

- (void)textViewDidEndEditing:(UITextView *)textView
{
    if (textView.text.length == 0) {
        textView.text = @"请对你发布的内容进行一个详细的描述";
        textView.textColor = [UIColor colorWithWhite:0.75 alpha:1.f];
    }
    
}


#pragma mark - 发布
- (void)btnClickRelease
{
    BOOL isOK = YES;
    
    
    if (isOK && tfTitle.text.length == 0) {
        isOK = NO;

        [self showSingleIconBubble:@"请输入标题"];

    }
    
    if (isOK && tfZhiWei.text.length == 0) {
        isOK = NO;
        [self showSingleIconBubble:@"请输入职位"];

    }
    
    
    if (isOK && tfPrice.text.length == 0) {
        isOK = NO;
        [self showSingleIconBubble:@"请输入薪资"];

    }
    
    if (isOK && [labHangYe.text isEqualToString:@"请选择行业"]) {
        isOK = NO;
        [self showSingleIconBubble:@"请选择行业"];

    }
    
    if (isOK && [labXueli.text isEqualToString:@"请选择学历要求"]) {
        isOK = NO;
        [self showSingleIconBubble:@"请选择学历"];

    }
    
    if (isOK && [labGZExprce.text isEqualToString:@"请选择工作经验"]) {
        isOK = NO;
        [self showSingleIconBubble:@"请选择工作经验"];
   }
    
    
    if (isOK && [labAddress.text isEqualToString:@"请选择地区"]) {
        isOK = NO;
        [self showSingleIconBubble:@"请选择地区"];

    }
    
    
    if (isOK) {
        if ([tvDetail.text isEqualToString:@"请对你发布的内容进行一个详细的描述"] || tvDetail.text.length == 0) {
            isOK = NO;
            [self showSingleIconBubble:@"请输入详细描述"];

        }
    }
    
    NSMutableString *strTagert = [NSMutableString string];
    if (btnTagert1.currentTitle.length != 0) {
        [strTagert appendString:btnTagert1.currentTitle];
        [strTagert appendString:@","];
    }
    if (btnTagert2.currentTitle.length != 0) {
        [strTagert appendString:btnTagert2.currentTitle];
        [strTagert appendString:@","];
    }
    if (btnTagert3.currentTitle.length != 0) {
        [strTagert appendString:btnTagert3.currentTitle];
        [strTagert appendString:@","];
    }
    
    if (strTagert.length != 0) {
        [strTagert deleteCharactersInRange:NSMakeRange(strTagert.length-1, 1)];
    }
    
    
    if (isOK) {
        //token=验证用户&userId=用户id&type=类型（1招聘 2求职）&title=标题&positionName=职位&address=工作地点&industry=行业&money=期望薪资&schooling=学历&experience=工作年限&description=描述 参数：photos-为图片zip包
        [self showRoundProgressWithTitle:@"请稍后..."];
        NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
        [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
        [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
        [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"usertype"] forKey:@"useType"];//用户类型
        [muDicParameters setObject:_strTypee forKey:@"type"];//类型（1招聘 2求职）
        [muDicParameters setObject:tfTitle.text forKey:@"title"];
        [muDicParameters setObject:tfPrice.text forKey:@"money"];
        [muDicParameters setObject:[NSString stringWithFormat:@"%@-%@-%@",provinceStr,cityStr,districtStr] forKey:@"address"];//工作地点
        [muDicParameters setObject:labHangYe.text forKey:@"industry"];//industry=行业
        [muDicParameters setObject:tfZhiWei.text forKey:@"positionName"];//职位
        [muDicParameters setObject:labXueli.text forKey:@"schooling"];//学历
        [muDicParameters setObject:labGZExprce.text forKey:@"experience"];//工作年限
        
        //&lable=标签&description=描述 参数：photo-为logo缩略图、photos-为图片zip包
        [muDicParameters setObject:tvDetail.text forKey:@"description"];
        if (strTagert.length != 0) {
            [muDicParameters setObject:strTagert forKey:@"lable"];
        }
        
        
        
        NSString *strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"addJobhunting_app_jobhunting.im.lensum"];
        
        AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
        [manager POST:strURl parameters:muDicParameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
            // 压缩
            NSMutableArray *aryImg = [NSMutableArray arrayWithArray:muArySaveImg];
            NSMutableArray *muSaveFull = [NSMutableArray array];
            [aryImg removeLastObject];
            for (int i = 0; i<aryImg.count; i++) {
                UIImage *image = aryImg[i];
                NSString *strName1 = [NSString stringWithFormat:@"%@.png",[self dateString]];
                [self saveImage:image withName:strName1];
                NSString *fullPath1 = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:strName1];
                [muSaveFull addObject:fullPath1];
            }
            
            
            NSString *zippedPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",[self dateString]]];
            
            BOOL isSucee = [SSZipArchive createZipFileAtPath:zippedPath withFilesAtPaths:muSaveFull];
            if (isSucee) {
                NSData *data1 = [NSData dataWithContentsOfFile:zippedPath];
                [formData appendPartWithFileData:data1 name:@"photos" fileName:@"photos.zip" mimeType:@"zip"];
            }
            
        } progress:^(NSProgress * _Nonnull uploadProgress) {
            
        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
            NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
            //NSLog(@"%@",dicInfo);

            if ([dicInfo[@"result"] integerValue] == 1) {

                [self showRightWithTitle:dicInfo[@"msg"] autoCloseTime:2];
                strID = dicInfo[@"data"];
                [self performSelector:@selector(btnDismiss) withObject:nil afterDelay:kHideHudDelay];
            }else {

                [self showSingleIconBubble:dicInfo[@"msg"]];
            }

        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

            [self showSingleIconBubble:error.localizedDescription];

        }];
        
    }
    
    
    
}

- (void)btnDismiss
{
    [self.navigationController popViewControllerAnimated:YES];
    
    NSMutableDictionary *muDic = [NSMutableDictionary dictionary];
    [muDic setObject:strID forKey:@"id"];
    if ([_strTypee integerValue] == 1) {//招聘
        [muDic setObject:@"5" forKey:@"type"];
    }else {
        [muDic setObject:@"6" forKey:@"type"];
    }
    
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"gotoPush" object:nil userInfo:muDic];
}


- (void)textFieldDidEndEditing:(UITextField *)textField
{
    if (textField == tfPrice) {
        if (tfPrice.text.length >16) {

            [self showSingleIconBubble:@"金额不能超过15位"];

            tfPrice.text = @"";
        }
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
